package com.xzy.controller;

import com.xzy.mapper.UserMapper;
import com.xzy.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Created by css on 2018/8/19.
 */
@Controller
@RequestMapping(value = "/test")
public class Test {
//    @Autowired
//    private SessionUtils sessionUtils;
    @Autowired
    private UserMapper userMapper;

    @RequestMapping(value = "login")
    //@ResponseBody
    public String sessionTest(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
//        User user = userMapper.findByUsername("root");
//        session.setAttribute("user1",user);
//        session.setAttribute("sessions",session.hashCode());
//        User user1 = (User)session.getAttribute("user");
//        if(user1==null){
//            session.setAttribute("userId","---------------------------");
//        }else{
//            session.setAttribute("userId",user1);
//        }
        session.setAttribute("loginSession","loginSession");
        return "test";
    }
    @RequestMapping(value = "show")
    public String show(HttpServletRequest request){
        //User attrivute = sessionUtils.getAttrivute(request);
        //request.getSession().setAttribute("dadada",attrivute);
        //System.out.println(attrivute+"--------");
        return "SessionTest";
    }
}
